<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('npc列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								npc姓名：<input type="text" name="npcName"/>
							</li>

							<li>
								npc类型：
								<select id="npcType" name="npcType" style="width:80px;">
									<option value="">全部</option>
									<option value="1">拜贤</option>
									<option value="2">寻物</option>
									<option value="3">送物</option>
								</select>
							</li>

							<li>
								npc通用话语：
								<select id="npcCommonTalkStatus" name="npcCommonTalkStatus" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								npc专有话语：
								<select id="npcSpecialTalkStatus" name="npcSpecialTalkStatus" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								npc问题答复：
								<select id="npcReplyStatus" name="npcReplyStatus" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								通用任务发放：
								<select id="npcCommonTaskStatus" name="npcCommonTaskStatus" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								专有任务发放：
								<select id="npcSpecialTaskStatus" name="npcSpecialTaskStatus" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								备注信息：<input type="text" name="remark"/>
							</li>

							<li>
								状态：
								<select id="delFlag" name="delFlag" style="width:80px;">
									<option value="">全部</option>
									<option value="0">正常</option>
									<option value="1">禁用</option>
								</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="fantasy:fantasyNpc:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit" onclick="$.operate.edit()" shiro:hasPermission="fantasy:fantasyNpc:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del" onclick="$.operate.removeAll()" shiro:hasPermission="fantasy:fantasyNpc:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="fantasy:fantasyNpc:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('fantasy:fantasyNpc:edit')}]];
        var removeFlag = [[${@permission.hasPermi('fantasy:fantasyNpc:remove')}]];
        var prefix = ctx + "fantasy/fantasyNpc";
		var npcType = [[${@dict.getType('npc_type')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "npc",
                search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'npcId', 
					title : 'npcid',
					visible: false
				},
				{
					field : 'npcName', 
					title : 'npc姓名',
					sortable: true
				},
				{
					field : 'npcDesc', 
					title : 'npc详情',
					sortable: true
				},
				{
					field : 'npcFace', 
					title : 'npc头像',
					sortable: true,
                    formatter: showImg,
                    events: 'operateEvents'
				},
				{
					field : 'npcType',
					title : 'npc类型',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(npcType, value);
					}
				},
				{
					field : 'npcCommonTalkStr',
					title : 'npc通用话语',
					sortable: true
				},
				{
					field : 'npcSpecialTalkStr',
					title : 'npc专有话语',
					sortable: true
				},
				{
					field : 'npcReplyStr',
					title : 'npc问题答复',
					sortable: true
				},
				{
					field : 'npcCommonTaskStr',
					title : '通用任务发放',
					sortable: true
				},
				{
					field : 'npcSpecialTaskStr',
					title : '专有任务发放',
					sortable: true
				},
				{
					field : 'createBy', 
					title : '创建者',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateBy', 
					title : '更新者',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注信息',
					sortable: true
				},
				{
					field : 'delFlag', 
					title : '状态',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.npcId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.npcId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        function showImg(value, row, index) {
            var imgSrc = ctx + 'profile/' + value;
            var s = '<a class = "view"  href="javascript:void(0)"><img style="width:30px;height:30px;"  src="'+imgSrc+'" /></a>';
            return s;
        }

        window.operateEvents = {
            'click .view': function (e, value, row, index) {
                var imgSrc = ctx + 'profile/' + value;
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    area: 'auto',
                    skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: true,
                    content: '<img src="'+imgSrc+'"/>'
                });
            },
        };
    </script>
</body>
</html>